package com.zixuan.controller;

import com.zixuan.common.Result;
import com.zixuan.common.dto.DeviceAndPurDTO;
import com.zixuan.entity.PurApplicationEntity;
import com.zixuan.service.PurDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/purApplication")
public class PurDeviceController {

    @Autowired
    private PurDeviceService purDeviceService;
    /**
     * 添加申请采购
     */
    @PostMapping("/purDevice")
    public Result purDevice(@RequestBody PurApplicationEntity purApplicationEntity){
        return purDeviceService.purDevice(purApplicationEntity);
    }
    /**
     * 得到所有的申请信息
     * */
    @GetMapping("/findAllPurApplication/{start}/{end}")
    public Result findAllPurApplication(@PathVariable("start") String start,@PathVariable("end") String end){
        return  purDeviceService.findAllPurApplication(start,end);
    }
    /**
     * 更新审批信息
     */
    @PutMapping("/permittedApplication")
    public Result permittedApplication(@RequestBody DeviceAndPurDTO deviceAndPurDTO){
        return purDeviceService.permittedApplication(deviceAndPurDTO);
    }
    //查询当前用户的申请列表
    @GetMapping("/findApplicationByUser/{start}/{end}/{userId}")
    public Result findApplicationByUserId(@PathVariable("start") String start,@PathVariable("end") String end,@PathVariable("userId") String userId){

        return purDeviceService.findApplicationByUserId(start,end,userId);
    }
}
